/**
 * 
 */
package com.usc.nearbyus;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

/**
 * 
 * This class deals with the user settings done for the application.
 * @author pranav
 *
 */
public class UserSettings {
	
	public static final String USER_ID = "userid";
	private static String TAG = "GPSLoggerService";
	
	
	/**
	 * This method would return the user-id set previously, 
	 * If not set then ....This method would return 0 as default value.
	 * 
	 * @param context
	 * @return
	 */
	public static String getUserID(Context context){
		SharedPreferences pref = context.getSharedPreferences(USER_ID, 0);	
	//	Log.d(TAG, "User ID inside usersettings : "+pref.getString(USER_ID, "notset"));
		return pref.getString(USER_ID, "notset");
	}
	
	/**
	 * This method sets the user ID for later retrieval
	 * @param context
	 * @param userid
	 */
	public static void setUserID(Context context, String userid){
		SharedPreferences pref = context.getSharedPreferences(USER_ID, 0);
		SharedPreferences.Editor editor = pref.edit();
		Log.d(TAG, "UserID Passed to the setID()" + userid);
		editor.putString(USER_ID,userid);
		if(editor.commit()){
			Log.d(TAG , "UserID Sucessfully changed");
			Log.d(TAG, "User ID inside SET after commit : "+pref.getLong(USER_ID, 123));
		}
		
		
	}

}
